package Thread;

import java.util.Scanner;

public class Demo8 {
    public static void main(String[] args) throws InterruptedException {
        Object locker = new Object();
        Thread t1 = new Thread(()-> {
            synchronized (locker) {


                System.out.println("t1等到之前");
                try {

                    locker.wait();

                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("t1等待之后");
            }
        });

        Thread t2 = new Thread(()-> {
            synchronized (locker) {
                System.out.println("t2通知之前");
                Scanner scanner = new Scanner(System.in);
                scanner.nextInt();
                locker.notify();
                System.out.println("t2通知之后");
            }

        });

        t1.start();
        t2.start();

        t1.join();
        t2.join();


    }
}
